import React from 'react'
// ===================================================================== Temp
// ===================================================================== global declare
const { $Lazy, $http } = window
// ===================================================================== Lazy
const Echart 		= $Lazy.load(()=>import('../../cpt/echart'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		data: [] 
	}

	init = () => {
		const { uuid } = this.props.thisRef.cRow
		$http.pull(null, 'qc-data/chart', {param: {test_id: uuid}}).then(({data, result_avg, x, y}) => this.setState({data: data.map(v => ({data: [v], result_avg, x, y}))}))
	}
	
	render(){
		const { data } = this.state
		return <>
			<div className='fxmj mtb5 plr5'>
				<span className='cp' style={{color: '#208FA0', fontWeight: 700, borderBottom: '2px solid #208FA0'}}>图表</span>
			</div>
			<div>
				{data.map((v, i) => this.props.levels.includes((i + 1).toString()) && <div key={i} className='mb10'><Echart type='line' rawData={v} /></div>)}
			</div>
		</>
	}
}

export default Index